﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<#include "/pages/include/include.ftl" />
<@h.css href="/css/uc.css"/>
<@h.js src="/javascripts/public/auth.js"/>
<#include "/pages/include/setlayout.ftl" />
<script type="text/javascript">
	var auth=new auth();
		$(function(){
			$("#navtab1").ligerTab({
				onBeforeSelectTabItem:function(TabID){
					if($('#tab').val()==TabID)
						return;
					$('#'+TabID).loading();
					window.location.href="?curTab="+TabID;
				}
			});
			
			//all select
			$('#ROLE .allSelect').click(function(){
				auth.checkRole($(this));
			});
			$('#USER .allSelect').click(function(){
				auth.checkUser($(this));
			});
			//delete
			$('#delRole').click(function(){
				auth.delRole();
			});
			$('#delUser').click(function(){
				auth.delUser();
			});
			$('#addRole').click(function(){
				auth.addRole();
			}); 
			$('#addUser').click(function(){
				auth.showAdd();
			});
			$('#batchSetFunc').click(function(){
				auth.batchSetFunc();
			});
			$('#batchSetRole').click(function(){
				auth.batchSetRole();
			});
			$('#batchSetCate').click(function(){
				auth.batchSetCate();
			});
		});
function keydown(e){
	 var code = window.event ? e.keyCode:e.which;
	if (code==13) {
		auth.search();
	}
}
</script>
<style>
.d{
overflow:auto;
}
</style>
</head>

<body onkeydown="javascript:keydown(event)">
<#assign menuId="auths">
<#setting number_format="0">
<div id="layout1" class="wrapper">
	
		<#include "/pages/include/top.ftl" />
		
	<#include "/pages/person/myfile/file_menu.ftl" />
	
	<div position="center" title="权限管理">
		<div class="content-section">
			<div id="navtab1">
			<#if action.hasAuth("AUTH_ROLE")> 
				<div id="ROLE" tabid="ROLE" <#if curTab='ROLE'>lselected="true"</#if>  title="角色管理">
					<div class="action-div">
					<#if action.hasAuth("AUTH_ROLE_DEL")>
						<a id="delRole" class="minibutton"><span>删除</span></a>
					</#if>
					<#if action.hasAuth("AUTH_ROLE_FUNC")>
						<a id="batchSetFunc" class="minibutton" style="width:90px;"><span>批量设置权限</span></a>
					</#if>
					<#if action.hasAuth("AUTH_ROLE_ADD")>
						<a id="addRole" class="minibutton" style="width:70px;"><span>新增角色</span></a>
					</#if>
					</div>
					<div  class="sList" >
					<table width="100%" class="sTable" cellpadding="0" cellspacing="0" border="0" >
						<tr>
							<td class="sTh checkbox" ><input class="inputCheckbox allSelect" type="checkbox" id="" name="" /></td>
							<th class="sTh">角色名称</th>
							<th class="sTh">权限</th>
							<th class="sTh">操作</th>
						</tr>
					<#if rolePage?exists>
					<#list rolePage.result as a>
						<tr class="<#if a_index%2==0>sRow2<#else>sRow1</#if>">
						<td class="sCell" ><input class="inputCheckbox selectItem" type="checkbox" value="${a.id?if_exists}" /></td>
							<td class="sCell" style="width:300px;">${a.name?if_exists}</td>
							<td class="sCell">${a.funcStr?if_exists}</td>
							<td class="sCell" style="width:300px;" align="left">
							<#if action.hasAuth("AUTH_ROLE_EDIT")>
								<a class="sliverbutton" onclick="auth.editRole('${a.id?if_exists}','${a.name?if_exists}');" style="width:43px;"><span>编辑</span></a>
							</#if>
							<#if action.hasAuth("AUTH_ROLE_FUNC")>
								<a class="sliverbutton" onclick="auth.setRoleFuncs('${a.id?if_exists}');" style="width:90px;"><span>设置功能权限</span></a>
							</#if>
							<#if action.hasAuth("AUTH_ROLE_CATE")>
								<#if !a.superAdmin>
								<a class="sliverbutton" onclick="auth.setRoleCates('${a.id}');" style="width:80px;"><span>设置读权限</span></a>
								</#if>
							</#if>
							</td>
						</tr>
					</#list>
					</#if>
					</table>
					</div>
					<@s.component id="page" template="components/page.ftl"> 
							<@s.param name="page" value="%{rolePage}" />
							<@s.param name="pageRange" value="%{pageRange}" />
							<@s.param name="param" value="%{action.param}" />
					</@s.component>
				</div>
			</#if>
			<#if action.hasAuth("AUTH_USER")> 
				<div id="USER" tabid="USER" <#if curTab='USER'>lselected="true"</#if> title="用户管理" >
					<div class="action-div" style="float:left;">
					<#if action.hasAuth("AUTH_USER_DEL")>
						<a id="delUser" class="minibutton"><span>删除</span></a>
					</#if>
					<#if action.hasAuth("AUTH_USER_ROLE")>
						<a id="batchSetRole" class="minibutton" style="width:90px;"><span>批量设置角色</span></a>
					</#if>
					<#if action.hasAuth("AUTH_USER_CATE")>
						<a id="batchSetCate" class="minibutton" style="width:90px;"><span>批量设读权限</span></a>
					</#if>
					<#if action.hasAuth("AUTH_USER_ADD")>
						<a id="addUser" class="minibutton" style="width:70px;"><span>新增用户</span></a>
					</#if>
						
					</div>
					<div class="action-div" style="float:right;margin-right:30px;">
						<form id="searchForm" action="auth-home.action" method="get">
						角色： <@s.select name="params.roleName" headerKey="-1" headerValue="请选择" list="roles" listKey="id" listValue="name"/>
						部门：<input type="text" class="inputText" value="${params.dept?if_exists}" name="params.dept" />
						登录ID：<input type="text" class="inputText" value="${params.username?if_exists}" name="params.username" />
						<a class="minibutton" href="javascript:auth.search();"><span>查询</span></a>
						<@s.hidden name="curTab" value="USER"/>
						</form>
					</div>
					<div  class="sList" >
					<table width="100%" class="sTable" cellpadding="0" cellspacing="0" border="0" >
						<tr>
							<td class="sTh checkbox" ><input class="inputCheckbox allSelect" type="checkbox" id="" name="" /></td>
							<th class="sTh">登录ID</th>
							<th class="sTh">实名</th>
							<th class="sTh">部门</th>
							<th class="sTh">角色</th>
							<th class="sTh">操作</th>
						</tr>
					<#if userPage?exists>
					<#list userPage.result as a>
						<tr class="<#if a_index%2==0>sRow2<#else>sRow1</#if>">
							<td class="sCell" ><input class="inputCheckbox selectItem" type="checkbox" value="${a.id}" /></td>
							<td class="sCell" style="width:300px;">${a.username?if_exists}</td>
							<td class="sCell">${a.realName?if_exists}</td>
							<td class="sCell">${a.deptment?if_exists}</td>
							<td class="sCell">${a.rolesStr?if_exists}</td>
							<td class="sCell" style="width:300px;" align="left">
							<#if action.hasAuth("AUTH_USER_ROLE")>
								<a class="sliverbutton" onclick="auth.setRoles('${a.id}');" style="width:70px;"><span>设置角色</span></a>
							</#if>
							<#if action.hasAuth("AUTH_USER_CATE")>
								<a class="sliverbutton" onclick="auth.setCates('${a.id}');" style="width:80px;"><span>设置读权限</span></a>
							</#if>
							<#if action.hasAuth("AUTH_USER_EDIT")> 
								<#if a.local>
									<a class="sliverbutton" onclick="auth.showEdit('${a.id}');" style="width:43px;"><span>编辑</span></a>
								</#if>
							</#if>
							</td>
						</tr>
					</#list>
					</#if>
					</table>
					</div>
					<@s.component id="page" template="components/page.ftl"> 
							<@s.param name="page" value="%{userPage}" />
							<@s.param name="pageRange" value="%{pageRange}" />
							<@s.param name="param" value="%{action.param}" />
					</@s.component>
				</div>
			</#if>
			</div>
		</div>
	</div>
	
	
	<#include "/pages/include/bottom.ftl" />
	
	<input type="hidden" id="tab" value="${curTab}"/>
</div>

</body>

</html>
